@extends('layouts.app')

@section('content')
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="card-title mb-0">作业详情</h5>
        <div>
            <a href="{{ route('assignments.edit', $assignment) }}" class="btn btn-primary btn-sm">
                <i class="fas fa-edit"></i> 编辑
            </a>
            <form action="{{ route('assignments.destroy', $assignment) }}" method="POST" class="d-inline">
                @csrf
                @method('DELETE')
                <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确定要删除这个作业吗？')">
                    <i class="fas fa-trash"></i> 删除
                </button>
            </form>
        </div>
    </div>
    <div class="card-body">
        <div class="row mb-4">
            <div class="col-md-6">
                <h6 class="text-muted">作业标题</h6>
                <p class="h5">{{ $assignment->title }}</p>
            </div>
            <div class="col-md-6">
                <h6 class="text-muted">截止日期</h6>
                <p class="h5">{{ $assignment->due_date->format('Y-m-d') }}</p>
            </div>
        </div>

        <div class="row mb-4">
            <div class="col-md-4">
                <h6 class="text-muted">作业来源</h6>
                <p>
                    <span class="badge bg-secondary">
                        @switch($assignment->source)
                            @case('school')
                                学校
                                @break
                            @case('institution')
                                机构
                                @break
                        @endswitch
                    </span>
                </p>
            </div>
            <div class="col-md-4">
                <h6 class="text-muted">科目</h6>
                <p>
                    <span class="badge bg-secondary">
                        @switch($assignment->subject)
                            @case('chinese')
                                语文
                                @break
                            @case('math')
                                数学
                                @break
                            @case('english')
                                英语
                                @break
                            @case('science')
                                科学
                                @break
                        @endswitch
                    </span>
                </p>
            </div>
            <div class="col-md-4">
                <h6 class="text-muted">作业类型</h6>
                <p>
                    <span class="assignment-type type-{{ $assignment->type }}">
                        @switch($assignment->type)
                            @case('daily')
                                每日作业
                                @break
                            @case('checkin')
                                每日打卡
                                @break
                            @case('weekly')
                                每周作业
                                @break
                        @endswitch
                    </span>
                </p>
            </div>
        </div>

        <div class="mb-4">
            <h6 class="text-muted">作业内容</h6>
            <div class="card">
                <div class="card-body">
                    {{ $assignment->content }}
                </div>
            </div>
        </div>

        <div class="mb-4">
            <h6 class="text-muted">完成状态</h6>
            @if($assignment->completions->where('student_id', auth()->id())->first()?->is_completed)
                <div class="alert alert-success">
                    <i class="fas fa-check"></i> 已完成
                    <small class="d-block">完成时间：{{ $assignment->completions->where('student_id', auth()->id())->first()->completed_at->format('Y-m-d H:i:s') }}</small>
                </div>
            @else
                <form action="{{ route('assignments.complete', $assignment) }}" method="POST">
                    @csrf
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-check"></i> 标记完成
                    </button>
                </form>
            @endif
        </div>

        <div class="d-grid">
            <a href="{{ route('assignments.index') }}" class="btn btn-secondary">返回列表</a>
        </div>
    </div>
</div>
@endsection 